<?php
	$obj=new ObjRequest();
	$obj->loadByKey($id);
	$us=new User();
	$us->loadByKey($obj->ResponseBy);
	include("FCKeditor/fckeditor.php");
	$post=new ObjPost();
	if ( strcasecmp( @ $_SERVER['REQUEST_METHOD'], 'POST' ) == 0 )
	{
		$post->RequestID=$id;
		$post->PostBy=$_SESSION['username'];
		$post->Detail=$_POST['Detail'];
		$post->insert($conn);
		foreach($_POST['Rows'] as $key =>$val)
		{
			$file=new ObjFile();
			$file->insert($conn,'subimageRow'.$key);
			$post->insertAttachment($conn,$file->FileID);
		}
		linkto("?module=tblrequest&action=detail&id=$id");
	}
?>
<form name="f" action="" method="post" enctype="multipart/form-data">
<div class="ContentTitle">
    <div class="left" style="padding-top:8px"><?php echo $objModule->ModuleName?></div>
    <div class="CMSButton right">
        <a href="?module=<?php echo $module?>">Back</a>
    </div>    
    <div class="clear"></div>
</div>
<ul id="ContentTabs" class="shadetabs">
    <li><a id="linkTab1" onclick="ShowHideDiv('Tab',1,2,'link')" class="selected">Request</a></li>    
</ul>       

<div id="Tab1" class="TabContainer ngt_Product">
<!-------------CONTENT OF EACH MODULE ---------------------------->
<table width="100%">
	<tr valign="top">
		<td width="15%">
			Create by: <?php echo $us->UserName?><br>
            Date: <?php echo dateFormat($obj->ResponseDate)?>
		</td>
		<td>
			<table width="100%">
            	<tr>
                	<td>
                        <?php echo $obj->Title?>
                    </td>
                </tr>
                <tr>
                	<td>
                    	<?php echo $obj->Detail?><br>
<?php
	$arr=$obj->getAttachment();
	for($i=0;$i<count($arr);$i++)
	{
		$file=new ObjFile();
		$file->loadByKey($arr[$i]["FileID"]);
?>
						<a href="modules/<?php echo $file->Table?>/<?php echo $file->FileName?>"><?php echo $file->FileName?></a>
<?php
	}
?>
                    </td>
                </tr>
            </table>
		</td>
	</tr>
</table>
<table width="100%">
<?php
	$data=$obj->getPost();
	for($j=0;$j<count($data);$j++)
	{
		$post->loadByKey($data[$j]);
		$us->loadByKey($post->PostBy);
?>
    <tr valign="top">
		<td width="15%">
			Post by: <?php echo $us->UserName?><br>
            Date: <?php echo dateFormat($post->LastUpdate)?>
		</td>
		<td>
			<table width="100%">
            	<tr>
                	<td>
                        <?php echo $post->Detail?>
                    </td>
                </tr>
                <tr>
                	<td>
                    	
<?php
		$arr=$post->getAttachment();
		for($i=0;$i<count($arr);$i++)
		{
			$file=new ObjFile();
			$file->loadByKey($arr[$i]["FileID"]);
?>
						<a href="modules/<?php echo $file->Table?>/<?php echo $file->FileName?>"><?php echo $file->FileName?></a>
<?php
		}
?>
                    </td>
                </tr>
            </table>
		</td>
	</tr>

<?php
	}
?>
</table>
<!-------------END CONTENT OF EACH MODULE ---------------------------->
</div>
</form>